package cn.tedu.egmvc2.controller;

import cn.tedu.egmvc2.mappers.AddressMapper;
import cn.tedu.egmvc2.pojo.entyti.Address;
import cn.tedu.egmvc2.pojo.vo.AddressVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address/")
public class AddressController {
    @Autowired
    private AddressMapper addressMapper;
    @RequestMapping("insert")
    public String insertAddress(AddressVO addressVO){
        Address address=new Address();
        BeanUtils.copyProperties(addressVO,address);
        addressMapper.insertAddress1(address);
        return "添加成功";
    }
    @RequestMapping("select")
    public List<Address> selectAddress(){
        return addressMapper.selectAddress1();
    }
    @RequestMapping("delete")
    public String deleteAddress(Integer id){
        addressMapper.deleteAddress1(id);
        return "删除成功";
    }
    @RequestMapping("update")
    public String updateAddress(Address address){
        addressMapper.updateAddress1(address);
        return "修改成功";
    }
}
